#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["WebAPI/WebAPI.csproj", "WebAPI/"]
COPY ["Demo.Kernel.Peasy/Demo.Kernel.Peasy.csproj", "Demo.Kernel.Peasy/"]
COPY ["Demo.Kernel.IService/Demo.Kernel.IService.csproj", "Demo.Kernel.IService/"]
COPY ["Demo.Kernel.Command/Demo.Kernel.Command.csproj", "Demo.Kernel.Command/"]
COPY ["Demo.Kernel.Model/Demo.Kernel.Model.csproj", "Demo.Kernel.Model/"]
COPY ["Demo.Kernel.EF/Demo.Kernel.EF.csproj", "Demo.Kernel.EF/"]
COPY ["Demo.Kernel.Handler/Demo.Kernel.Handler.csproj", "Demo.Kernel.Handler/"]
COPY ["Demo.Kernel.Workflow/Demo.Kernel.Workflow.csproj", "Demo.Kernel.Workflow/"]
COPY ["Demo.Kernel.Repository/Demo.Kernel.Repository.csproj", "Demo.Kernel.Repository/"]
COPY ["Demo.Kernel.Service/Demo.Kernel.Service.csproj", "Demo.Kernel.Service/"]
RUN dotnet restore "WebAPI/WebAPI.csproj"
COPY . .
WORKDIR "/src/WebAPI"
RUN dotnet build "WebAPI.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "WebAPI.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Demo.WebAPI.dll"]